I don't think the standard specifies the factor. I think VC++ implementation uses a smaller factor than GCC, which might actually be 1.5.
I don't think the standard specifies the factor. I think VC++ implementation uses a smaller factor than GCC, which might actually be 1.5.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Factor of 2 expansion is how you see it presented in most algo. textbooks. I like a factor of 1.5 since it requires a little less memory at the expense of a little more resizing. Both algorithms are of course linear complexity. That is the complexity of appending n items is proportional to n , O(n).
Also a factor of 1.5 is easy to generate via a shift and an add once you take care of end cases.
I double checked, and I think that you are right, the standard only seems to specify amortised constant time for std::vector's push_back().Originally Posted by anon
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)